import '../apis/resquest/http.dart';
import '../model/bean/maintenance_details_bean.dart';
import '../model/bean/maintenance_plan_bean.dart';
import '../model/bean/maintenance_record_bean.dart';
import '../model/bean/todo_bean.dart';
import '../model/bean/todo_details_bean.dart';

class Maintenance {
  /// 查询今日待办列表
  /// * [data] Map|请求参数|必填
  static queryTodayToDo(Map<String, dynamic> data) async {
    const url = '/elevator-maintenance-app/maintenance/getToDo';
    try {
      HttpResponse _r = await Http.getInstance().get(url, params: data);
      return TodoListBean.fromJson(_r.data);
    } catch (e) {}
  }

  /// 查询今日待办详情
  /// * [data] Map|请求参数|必填
  static queryTodoDetails(Map<String, dynamic> data) async {
    const url = '/elevator-maintenance-app/maintenance/getById';
    try {
      HttpResponse _r = await Http.getInstance().get(url, params: data);
      return TodoDetailsBean.fromJson(_r.data);
    } catch (e) {}
  }

  /// 完成今日待办事项
  /// * [data] Map|请求参数|必填
  static completeTodo(Map<String, dynamic> data) async {
    const url = '/elevator-maintenance-app/maintenance/complete';
    try {
      HttpResponse _r = await Http.getInstance().post(url, params: data);
      return _r.msg;
    } catch (e) {}
  }

  /// 查询维保计划
  /// * [data] Map|请求参数|必填
  static queryMaintenancePlan(Map<String, dynamic> data) async {
    const url = '/elevator-maintenance-app/maintenance/getByMaintainer';
    try {
      HttpResponse _r = await Http.getInstance().get(url, params: data);
      return MaintenancePlanListBean.fromJson(_r.data);
    } catch (e) {}
  }

  /// 查询维保记录
  /// * [data] Map|请求参数|必填
  static queryMaintenanceRecord(Map<String, dynamic> data) async {
    const url = '/elevator-maintenance-app/maintenance/elevatorPlans';
    try {
      HttpResponse _r = await Http.getInstance().get(url, params: data);
      return MaintenanceListRecordBean.fromJson(_r.data);
    } catch (e) {}
  }

  /// 查询维保详情
  /// * [data] Map|请求参数|必填
  static queryMaintenanceDetails(Map<String, dynamic> data) async {
    const url = '/elevator-maintenance-app/maintenance/getById';
    try {
      HttpResponse _r = await Http.getInstance().get(url, params: data);
      return MaintenanceDetailsBean.fromJson(_r.data);
    } catch (e) {
      //print("报错了：$e");
    }
  }
}
